package lumis.doui.table.filter;

import lumis.doui.table.TableSource;
import lumis.portal.PortalException;
import lumis.util.XmlUtil;

import org.w3c.dom.Node;

/**
 * Base class for table source filters. 
 *
 * @version $Revision: 8618 $ $Date: 2007-12-18 11:34:20 -0200 (Tue, 18 Dec 2007) $
 * @since 4.1.0
 */
public abstract class AbstractTableSourceFilter implements ITableSourceFilter
{
	private TableSource source;
	private String id;

	public void init(TableSource source, Node filterNode) throws PortalException
	{
		setSource(source);
		setId(XmlUtil.readAttributeString("id", filterNode));
	}
	
	public ITableSourceFilter getFilter(String filterId) throws PortalException
	{
		if (filterId.equals(getId()))
			return this;
		else
			return null;
	}

	public String getInputControlType() throws PortalException
	{
		return "lum_inputText";	
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public TableSource getSource()
	{
		return source;
	}

	public void setSource(TableSource source)
	{
		this.source = source;
	}
}
